﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace OnlineRailway.UI.Client
{
    public partial class ScheduleView : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["RailwayOnlineConnectionString"].ToString());
        private SqlDataAdapter dap;
        private SqlCommand comm;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            comm = con.CreateCommand();
            comm.CommandText = "SELECT * FROM TrainSchedules WHERE StartStation LIKE '%' + @start + '%'";
            comm.Parameters.AddWithValue("@start", txtStart.Text);
            dap = new SqlDataAdapter(comm);
            con.Open();
            DataSet ds = new DataSet();
            dap.Fill(ds);
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
            con.Close();
        }
    }
}